package model

import (
	"database/sql/driver"
	"encoding/json"
	"sensi/common/sys/database"
)

type WeatherHourly struct {
	City     string   `json:"city"`
	InHour   string   `json:"in_hour"`
	Location string   `json:"location"`
	Weather  *Weather `json:"weather"`
	database.Model
}

func (WeatherHourly) TableName() string {
	return "weather_hourly"
}

type Weather struct {
	Temp     string `json:"temp"`
	Icon     string `json:"icon"`
	Humidity string `json:"humidity"`
}

// Value ...
func (w Weather) Value() (driver.Value, error) {
	b, err := json.Marshal(w)
	return string(b), err
}

// Scan ...
func (w *Weather) Scan(input interface{}) error {
	return json.Unmarshal(input.([]byte), w)
}
